package com.dime.basic.service.impl;

import java.util.List;

import com.dime.basic.mapper.DimeBasecontraindicationMapper;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.uuid.IdUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dime.basic.mapper.DimeBasecontraindicationcriterionMapper;
import com.dime.basic.api.domain.DimeBasecontraindicationcriterion;
import com.dime.basic.service.IDimeBasecontraindicationcriterionService;

/**
 * 职业诊断标准禁忌症Service业务层处理
 * 
 * @author Tiny
 * @date 2023-10-13
 */
@Service
public class DimeBasecontraindicationcriterionServiceImpl implements IDimeBasecontraindicationcriterionService 
{
    @Autowired
    private DimeBasecontraindicationcriterionMapper dimeBasecontraindicationcriterionMapper;

    @Autowired
    private DimeBasecontraindicationMapper dimeBasecontraindicationMapper;

    /**
     * 查询职业诊断标准禁忌症
     * 
     * @param id 职业诊断标准禁忌症主键
     * @return 职业诊断标准禁忌症
     */
    @Override
    public DimeBasecontraindicationcriterion selectDimeBasecontraindicationcriterionById(String id)
    {
        return dimeBasecontraindicationcriterionMapper.selectDimeBasecontraindicationcriterionById(id);
    }

    /**
     * 查询职业诊断标准禁忌症列表
     * 
     * @param dimeBasecontraindicationcriterion 职业诊断标准禁忌症
     * @return 职业诊断标准禁忌症
     */
    @Override
    public List<DimeBasecontraindicationcriterion> selectDimeBasecontraindicationcriterionList(DimeBasecontraindicationcriterion dimeBasecontraindicationcriterion)
    {
        return dimeBasecontraindicationcriterionMapper.selectDimeBasecontraindicationcriterionList(dimeBasecontraindicationcriterion);
    }

    /**
     * 新增职业诊断标准禁忌症
     * 
     * @param dimeBasecontraindicationcriterion 职业诊断标准禁忌症
     * @return 结果
     */
    @Override
    public int insertDimeBasecontraindicationcriterion(DimeBasecontraindicationcriterion dimeBasecontraindicationcriterion)
    {
        SetCationcriterionName(dimeBasecontraindicationcriterion);
        dimeBasecontraindicationcriterion.setId(IdUtils.fastUUID());
        dimeBasecontraindicationcriterion.setCreateBy(SecurityUtils.getUsername());
        dimeBasecontraindicationcriterion.setCreateTime(DateUtils.getNowDate());
        return dimeBasecontraindicationcriterionMapper.insertDimeBasecontraindicationcriterion(dimeBasecontraindicationcriterion);
    }

    private void SetCationcriterionName(DimeBasecontraindicationcriterion dimeBasecontraindicationcriterion) {
        String cationcriterionName = dimeBasecontraindicationMapper.selectDimeBasecontraindicationById(dimeBasecontraindicationcriterion.getCationcriterionId()).getName();
        dimeBasecontraindicationcriterion.setCationcriterionName(cationcriterionName);
    }

    /**
     * 修改职业诊断标准禁忌症
     * 
     * @param dimeBasecontraindicationcriterion 职业诊断标准禁忌症
     * @return 结果
     */
    @Override
    public int updateDimeBasecontraindicationcriterion(DimeBasecontraindicationcriterion dimeBasecontraindicationcriterion)
    {
        SetCationcriterionName(dimeBasecontraindicationcriterion);;
        dimeBasecontraindicationcriterion.setUpdateBy(SecurityUtils.getUsername());
        dimeBasecontraindicationcriterion.setUpdateTime(DateUtils.getNowDate());
        return dimeBasecontraindicationcriterionMapper.updateDimeBasecontraindicationcriterion(dimeBasecontraindicationcriterion);
    }

    /**
     * 批量删除职业诊断标准禁忌症
     * 
     * @param ids 需要删除的职业诊断标准禁忌症主键
     * @return 结果
     */
    @Override
    public int deleteDimeBasecontraindicationcriterionByIds(String[] ids)
    {
        return dimeBasecontraindicationcriterionMapper.deleteDimeBasecontraindicationcriterionByIds(ids);
    }

    /**
     * 删除职业诊断标准禁忌症信息
     * 
     * @param id 职业诊断标准禁忌症主键
     * @return 结果
     */
    @Override
    public int deleteDimeBasecontraindicationcriterionById(String id)
    {
        return dimeBasecontraindicationcriterionMapper.deleteDimeBasecontraindicationcriterionById(id);
    }
}
